package com.ckjava.test.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class WebAppConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        /**
         * 自动将 `src\main\resources\webStatic` 目录的文件映射到 /**
         * /** 表示匹配任意层级的目录和文件
         */
        //registry.addResourceHandler(new String[]{"/**"}).addResourceLocations("classpath:/webStatic/").setCacheControl(CacheControl.noCache());

        registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
    }

}
